]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
slider: Request a size
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 26 Oct 2023 11:39:38 +0000 (13:39 +0200)
committerMarge Bot <marge-bot@gnome.org>
Tue, 21 Nov 2023 18:55:47 +0000 (18:55 +0000)
Sliders (and level bars) currently don't request any size, so it's
up to the caller (or stylesheet) to explicitly set a size big
enough to fit the bar/handle.

That's rather unexpected, we should request the size we need ourselves.

Closes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7133

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2994>

js/ui/barLevel.js
js/ui/slider.js

index 8ff648c17383d6de421219a63a4c6976a344b94e..1b4b7f940311d422df60d16da1865b65eba59256 100644 (file)
@@ -259,6 +259,26 @@ export const BarLevel = GObject.registerClass({
         cr.$dispose();
     }
 
+    vfunc_get_preferred_height(_forWidth) {
+        const themeNode = this.get_theme_node();
+        const height = this._getPreferredHeight();
+        return themeNode.adjust_preferred_height(height, height);
+    }
+
+    vfunc_get_preferred_width(_forHeight) {
+        const themeNode = this.get_theme_node();
+        const width = this._getPreferredWidth();
+        return themeNode.adjust_preferred_width(width, width);
+    }
+
+    _getPreferredHeight() {
+        return this._barLevelHeight + this._barLevelBorderWidth;
+    }
+
+    _getPreferredWidth() {
+        return this._overdriveSeparatorWidth + this._barLevelBorderWidth;
+    }
+
     _getCurrentValue() {
         return this._value;
     }
index f154cea40d10a5d24a84a216d89b7d0f5a2d1fd4..69288e7c6450fe013e75f01063b428240f2ea269 100644 (file)
@@ -75,6 +75,18 @@ export const Slider = GObject.registerClass({
         cr.$dispose();
     }
 
+    _getPreferredHeight() {
+        const barHeight = super._getPreferredHeight();
+        const handleHeight = 2 * this._handleRadius + this._handleBorderWidth;
+        return Math.max(barHeight, handleHeight);
+    }
+
+    _getPreferredWidth() {
+        const barWidth = super._getPreferredWidth();
+        const handleWidth = 2 * this._handleRadius + this._handleBorderWidth;
+        return Math.max(barWidth, handleWidth);
+    }
+
     vfunc_button_press_event(event) {
         return this.startDragging(event);
     }